﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Media;
using Microsoft.Multipoint.Sdk;
using System.Windows.Input;

namespace MultiPointDemoApp
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
            this.KeyDown += new System.Windows.Input.KeyEventHandler(MainWindow_KeyDown);
        }

        void MainWindow_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
                this.Close();
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            MultipointSdk.Instance.Register(this);
            for (int i = 0; i < MultipointSdk.Instance.MouseDeviceList.Count; i++)
            {
                DeviceInfo di = MultipointSdk.Instance.MouseDeviceList[i];
                DrawingAttributes da = new DrawingAttributes();
                da.Color = Colors.Red;
                da.Width = 2 * (i + 1); da.Height = 2 * (i + 1);
                ink1.MouseDrawingAttributes.Add(di.DeviceId, da);
            }
            //XmlSerializer xmlWriter = new XmlSerializer(cb.GetType());
            
            //StreamWriter xmlFile = new StreamWriter("Serialize.xml");
            //xmlWriter.Serialize(xmlFile, mic);
            //xmlFile.Close();
        }

        private void MultipointCheckBox_MultipointChecked(object sender, RoutedEventArgs e)
        {
            ink1.EditingMode = InkCanvasEditingMode.Select;
        }

        private void MultipointCheckBox_MultipointUnchecked(object sender, RoutedEventArgs e)
        {
            ink1.EditingMode = InkCanvasEditingMode.Ink;
        }
    }
}
